package com.mijie.core;

/**
 *  create table regionInfo(
	  latitudePrefix int(3) not null default 0,
	  longitudePrefix int(3) not null default 0,
	  latitude double not null default 0,
	  longitude double not null default 0,
	  province varchar(30) not null default '',
	  city varchar(30) not null default '',
	  district varchar(20) not null default '',
	  simpleProvince varchar(30) not null default '',
	  simpleCity varchar(30) not null default '',
	  index ll(latitude,longitude)
)ENGINE=memory DEFAULT CHARSET=utf8; 
 */
public class RegionInfo {

	private int latitudePrefix;
	private int longitudePrefix;
	private double latitude;
	private double longitude;
	private String province;
	private String city;
	private String district;
	private String simpleProvince;
	private String simpleCity;
	
	public int getLatitudePrefix() {
		return latitudePrefix;
	}
	public void setLatitudePrefix(int latitudePrefix) {
		this.latitudePrefix = latitudePrefix;
	}
	public int getLongitudePrefix() {
		return longitudePrefix;
	}
	public void setLongitudePrefix(int longitudePrefix) {
		this.longitudePrefix = longitudePrefix;
	}
	public double getLatitude() {
		return latitude;
	}
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}
	public double getLongitude() {
		return longitude;
	}
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getDistrict() {
		return district;
	}
	public void setDistrict(String district) {
		this.district = district;
	}
	public String getSimpleProvince() {
		return simpleProvince;
	}
	public void setSimpleProvince(String simpleProvince) {
		this.simpleProvince = simpleProvince;
	}
	public String getSimpleCity() {
		return simpleCity;
	}
	public void setSimpleCity(String simpleCity) {
		this.simpleCity = simpleCity;
	}
	public String toSimpleAddress(){
		StringBuilder sb = new StringBuilder();
		if(simpleProvince!=null && !simpleProvince.isEmpty()){
			sb.append(simpleProvince).append(" ");
			if(simpleCity!=null && !simpleCity.isEmpty() && !simpleCity.equals(simpleProvince)){
				sb.append(simpleCity);
			}
			if(district!=null && !district.isEmpty()) sb.append(district);
		}
		return sb.toString();
	}
	public String toAddress(){
		StringBuilder sb = new StringBuilder();
		if(province!=null && !province.isEmpty()){
			sb.append(province).append(" ");
			if(city!=null && !city.isEmpty() && !city.equals(province)){
				sb.append(city);
			}
			if(district!=null && !district.isEmpty()) sb.append(district);
		}
		return sb.toString();
	}
	
	@Override
	public String toString() {
		return "RegionInfo [latitudePrefix=" + latitudePrefix
				+ ", longitudePrefix=" + longitudePrefix + ", latitude="
				+ latitude + ", longitude=" + longitude + ", province="
				+ province + ", city=" + city + ", district=" + district
				+ ", simpleProvince=" + simpleProvince + ", simpleCity="
				+ simpleCity + "]";
	}
	
}
